package c.m.d.b.service;

import c.m.d.b.beans.EntityInstance;
import c.m.d.b.beans.PropertyValue;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;

@Transactional(propagation = Propagation.REQUIRED)
public interface EntityInstanceService
{

    //POST /{typename}/instance
    public
    @NotEmpty
    String createEntityInstance(@NotNull final EntityInstance entityInstance);

    //POST /{typename}/instance/{id}
    public void updateEntityInstance(@NotNull EntityInstance entityInstance);

    //DELETE /{typename}/instance/{id}
    public void deleteEntityInstance(@NotEmpty String entityInstanceId);

    //GET /{typename}/instance/{id}
    public
    @NotNull
    EntityInstance getEntityInstance(@NotEmpty String entityType, @NotEmpty String entityInstanceId);

    //GET /{typename}/instance
    public
    @NotNull
    List<EntityInstance> getEntityInstances(@NotEmpty String entityType);

    //POST /{typename}/instance/{id}/properties
    public void updateEntityInstanceProperties(@NotEmpty String entityTypeName, @NotEmpty String entityInstanceId,
            @NotEmpty Set<PropertyValue> propertyInstances);

    //POST /{typename}/instance/{id}/properties/{idlist}
    public void deleteEntityInstanceProperties(@NotEmpty String entityTypeName, @NotEmpty String entityInstanceId,
            @NotEmpty Set<String> propertyNames);

}
